package com.liu.consumer.mq;

import com.alibaba.fastjson.JSON;
import com.liu.User;
import com.liu.consumer.annotation.ConsumerClient;
import com.liu.consumer.config.Client;
import lombok.extern.slf4j.Slf4j;

import java.util.LinkedHashMap;
import java.util.List;

@Slf4j
@ConsumerClient("user")
public class FirstConsumer implements Client {

    private volatile boolean running =false;


    @Override
    public boolean isRunning() {
        return running;
    }

    @Override
    public void setRunning(boolean running) {
        this.running=running;
    }

    @Override
    public void handler(List<LinkedHashMap<String, Object>> links) {
        links.forEach(l->{
            String json = (String) l.get("body");
            User user = JSON.parseObject(json, User.class);
            System.out.println(user);
        });
    }

}